<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<script type="text/javascript">
$(function() {
	$(".msgText").css("width", "500px");
});

function setServer(serverstatus) {
	$.ajax({
		type: "post",
		url: "./setServer.ga",
		dataType: "html",
		data: {
			tag: "setServer",
			serverstatus: serverstatus
		},
		success: function(data) {
			if(data > 0) {
				if(serverstatus == 0) {
					$("#setServerBtn0").attr("disabled", true);
					$("#setServerBtn1").attr("disabled", false);
					$("#serverInfoText").html("서버 정지");
					$("#serverInfoText").css("color", "#ee9922");
				} else if(serverstatus == 1) {
					$("#setServerBtn0").attr("disabled", false);
					$("#setServerBtn1").attr("disabled", true);
					$("#serverInfoText").html("서버 활성");
					$("#serverInfoText").css("color", "#2299ee");
				}
			}
		},
		error: function() {
			alert("오류");
		}
	});
}

function updateMsg(msgnum) {
	$.ajax({
		type: "post",
		url: "./setServer.ga",
		dataType: "html",
		data: {
			tag: "updateMsg",
			msgnum: msgnum,
			msg: $("#msg" + msgnum).val()
		},
		success: function(data) {
			alert("메시지 변경 성공");
		},
		error: function() {
			alert("오류");
		}
	});
}
</script>

</head>
<body>

<h2>서버 관리</h2>
<br/>

서버 ON/OFF : &nbsp; 
	<c:if test="${resultMap.serverstatus == 0 }">
		<input type="button" id="setServerBtn1" value="ON" onclick="setServer(1)"/> &nbsp;
		<input type="button" id="setServerBtn0" value="OFF" onclick="setServer(0)" disabled/> &nbsp;&nbsp; 
		<span id="serverInfoText" style="font-size:9pt;color:#ee9922;">서버 정지</span>
	</c:if>
	<c:if test="${resultMap.serverstatus == 1 }">
		<input type="button" id="setServerBtn1" value="ON" onclick="setServer(1)" disabled/> &nbsp;
		<input type="button" id="setServerBtn0" value="OFF" onclick="setServer(0)"/> &nbsp;&nbsp; 
		<span id="serverInfoText" style="font-size:9pt;color:#2299ee;">서버 활성</span>
	</c:if>

<br/><br/><br/><br/>

메시지 관리<br/>
<table>
	<tr>
		<td>msg1</td>
		<td><input class="msgText" id="msg1" type="text" value="${resultMap.msg1 }"/></td>
		<td><input type="button" value="수정" onclick="updateMsg(1)"/></td>
	</tr>
	<tr>
		<td>msg2</td>
		<td><input class="msgText" id="msg2" type="text" value="${resultMap.msg2 }"/></td>
		<td><input type="button" value="수정" onclick="updateMsg(2)"/></td>
	</tr>
	<tr>
		<td>msg3</td>
		<td><input class="msgText" id="msg3" type="text" value="${resultMap.msg3 }"/></td>
		<td><input type="button" value="수정" onclick="updateMsg(3)"/></td>
	</tr>
	<tr>
		<td>msg4</td>
		<td><input class="msgText" id="msg4" type="text" value="${resultMap.msg4 }"/></td>
		<td><input type="button" value="수정" onclick="updateMsg(4)"/></td>
	</tr>
	<tr>
		<td>msg5</td>
		<td><input class="msgText" id="msg5" type="text" value="${resultMap.msg5 }"/></td>
		<td><input type="button" value="수정" onclick="updateMsg(5)"/></td>
	</tr>
</table>

</body>
</html>